<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>keydown、keyup、keypress</title>
</head>
<body>
<script>
    document.onkeydown = function (e) {
        console.log(e);//charCode: 0

    };

    document.onkeypress = function (e) {
        console.log(e);//charCode: 97
        console.log("a"+String.fromCharCode(e.charCode));
    }






//1、第一次运行
    // document.onkeydown = function () {
    //     console.log("keydown");
    // };
    //
    // document.onkeypress = function () {
    //     console.log("onkeypress");
    // }
    // document.onkeyup = function () {
    //     console.log("onkeyup");
    // };
</script>
</body>
</html>
